package com.library.web.controller.library;


import com.library.common.annotation.Log;
import com.library.common.core.controller.BaseController;
import com.library.common.core.domain.AjaxResult;
import com.library.common.core.page.TableDataInfo;
import com.library.common.enums.BusinessType;
import com.library.common.utils.poi.ExcelUtil;
import com.library.domain.BoSignIntegral;
import com.library.service.IBoSignIntegralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 签到积分 信息操作处理
 *
 * @author null
 * @date 2020-01-18
 */
@RestController
@RequestMapping("/library/boSignIntegral")
public class BoSignIntegralController extends BaseController {

    @Autowired
    private IBoSignIntegralService boSignIntegralService;

    /**
     * 查询签到积分列表
     */
    @PreAuthorize("@ss.hasPermi('system:integral:list')")
    @GetMapping("/list")
    public TableDataInfo list(BoSignIntegral boSignIntegral) {
        startPage();
        List<BoSignIntegral> list = boSignIntegralService.selectBoSignIntegralList(boSignIntegral);
        return getDataTable(list);
    }

    /**
     * 导出签到积分列表
     */
    @PreAuthorize("@ss.hasPermi('system:integral:export')")
    @Log(title = "签到积分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoSignIntegral boSignIntegral) {
        List<BoSignIntegral> list = boSignIntegralService.selectBoSignIntegralList(boSignIntegral);
        ExcelUtil<BoSignIntegral> util = new ExcelUtil<BoSignIntegral>(BoSignIntegral.class);
        util.exportExcel(response, list, "签到积分数据");
    }

    /**
     * 获取签到积分详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:integral:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(boSignIntegralService.selectBoSignIntegralById(id));
    }

    /**
     * 新增签到积分
     */
    @PreAuthorize("@ss.hasPermi('system:integral:add')")
    @Log(title = "签到积分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoSignIntegral boSignIntegral) {
        return toAjax(boSignIntegralService.insertBoSignIntegral(boSignIntegral));
    }

    /**
     * 修改签到积分
     */
    @PreAuthorize("@ss.hasPermi('system:integral:edit')")
    @Log(title = "签到积分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoSignIntegral boSignIntegral) {
        return toAjax(boSignIntegralService.updateBoSignIntegral(boSignIntegral));
    }

    /**
     * 删除签到积分
     */
    @PreAuthorize("@ss.hasPermi('system:integral:remove')")
    @Log(title = "签到积分", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(boSignIntegralService.deleteBoSignIntegralByIds(ids));
    }

}
